﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace iNet.Media.Imaging
{
	/// <summary>
	/// 無特定內部格式的影像中繼資料。
	/// </summary>
	public class GenericImageMetadata : GenericMetadata, IImageMetadata
	{
		#region 建構子
		/// <summary>
		/// 初始化新的 GenericImageMetadata 執行個體。
		/// </summary>
		public GenericImageMetadata()
		{ }
		/// <summary>
		/// 初始化新的 GenericImageMetadata 執行個體。
		/// </summary>
		/// <param name="template">範本中繼資料。</param>
		/// <param name="isReadOnly">是否為唯讀。</param>
		public GenericImageMetadata(IMetadata template, bool isReadOnly)
			: base(template, isReadOnly)
		{ }
		#endregion
		#region Aperture
		/// <summary>
		/// 取得或設定光圈值。
		/// </summary>
		public double? Aperture
		{
			get
			{
				return this.GetProperty<double?>("Aperture");
			}
			set
			{
				this.SetProperty("Aperture", value);
			}
		}
		#endregion
		#region CameraManufacturer
		/// <summary>
		/// 取得或設定相機製造商。
		/// </summary>
		public string CameraManufacturer
		{
			get
			{
				return this.GetProperty<string>("CameraManufacturer");
			}
			set
			{
				this.SetProperty("CameraManufacturer", value);
			}
		}
		#endregion
		#region CameraModel
		/// <summary>
		/// 取得或設定相機型號。
		/// </summary>
		public string CameraModel
		{
			get
			{
				return this.GetProperty<string>("CameraModel");
			}
			set
			{
				this.SetProperty("CameraModel", value);
			}
		}
		#endregion
		#region Clone
		/// <summary>
		/// 建立可修改的 GenericImageMetadata 副本。
		/// </summary>
		/// <returns>GenericImageMetadata 副本。</returns>
		public override object Clone()
		{
			return new GenericImageMetadata(this, false);
		}
		#endregion
		#region CopyFrom
		/// <summary>
		/// 從指定的中繼資料複製屬性。
		/// </summary>
		/// <param name="metadata">指定的中繼資料。</param>
		/// <exception cref="InvalidOperationException">中繼資料為唯讀。</exception>
		public override void CopyFrom(IMetadata metadata)
		{
			//確認狀態
			if (this.IsReadOnly)
				throw new InvalidOperationException();

			//複製
			IImageMetadata imageMetadata = (metadata as IImageMetadata);
			if (imageMetadata != null)
			{
				this.Aperture = imageMetadata.Aperture;
				this.CameraManufacturer = imageMetadata.CameraManufacturer;
				this.CameraModel = imageMetadata.CameraManufacturer;
				this.ExposureCompensation = imageMetadata.ExposureCompensation;
				this.ExposureProgram = imageMetadata.ExposureProgram;
				this.FlashManufacturer = imageMetadata.FlashManufacturer;
				this.FlashModel = imageMetadata.FlashModel;
				this.FlashState = imageMetadata.FlashState;
				this.FocalLength = imageMetadata.FocalLength;
				this.FocalLengthIn35mmFilm = imageMetadata.FocalLengthIn35mmFilm;
				this.GeoCoordinate = imageMetadata.GeoCoordinate;
				this.ISO = imageMetadata.ISO;
				this.LensManufacturer = imageMetadata.LensManufacturer;
				this.LensModel = imageMetadata.LensModel;
				this.Orientation = imageMetadata.Orientation;
				this.People = imageMetadata.People;
				this.ShutterSpeed = imageMetadata.ShutterSpeed;
			}

			//呼叫基底
			base.CopyFrom(metadata);
		}
		#endregion
		#region ExposureCompensation
		/// <summary>
		/// 取得或設定曝光補償值。
		/// </summary>
		public double? ExposureCompensation
		{
			get
			{
				return this.GetProperty<double?>("ExposureCompensation");
			}
			set
			{
				this.SetProperty("ExposureCompensation", value);
			}
		}
		#endregion
		#region ExposureProgram
		/// <summary>
		/// 取得或設定曝光程式。
		/// </summary>
		public ExposureProgram? ExposureProgram
		{
			get
			{
				return this.GetProperty<ExposureProgram?>("ExposureProgram");
			}
			set
			{
				this.SetProperty("ExposureProgram", value);
			}
		}
		#endregion
		#region FlashManufacturer
		/// <summary>
		/// 取得或設定閃光燈製造商。
		/// </summary>
		public string FlashManufacturer
		{
			get
			{
				return this.GetProperty<string>("FlashManufacturer");
			}
			set
			{
				this.SetProperty("FlashManufacturer", value);
			}
		}
		#endregion
		#region FlashModel
		/// <summary>
		/// 取得或設定閃光燈型號。
		/// </summary>
		public string FlashModel
		{
			get
			{
				return this.GetProperty<string>("FlashModel");
			}
			set
			{
				this.SetProperty("FlashModel", value);
			}
		}
		#endregion
		#region FlashState
		/// <summary>
		/// 取得或設定閃光燈狀態。
		/// </summary>
		public FlashState? FlashState
		{
			get
			{
				return this.GetProperty<FlashState?>("FlashState");
			}
			set
			{
				this.SetProperty("FlashState", value);
			}
		}
		#endregion
		#region FocalLength
		/// <summary>
		/// 取得或設定實際焦距，單位為毫米 (mm)。
		/// </summary>
		public double? FocalLength
		{
			get
			{
				return this.GetProperty<double?>("FocalLength");
			}
			set
			{
				this.SetProperty("FocalLength", value);
			}
		}
		#endregion
		#region FocalLengthIn35mmFilm
		/// <summary>
		/// 取得或設定等效焦距，單位為毫米 (mm)。
		/// </summary>
		public double? FocalLengthIn35mmFilm
		{
			get
			{
				return this.GetProperty<double?>("FocalLengthIn35mmFilm");
			}
			set
			{
				this.SetProperty("FocalLengthIn35mmFilm", value);
			}
		}
		#endregion
		#region GeoCoordinate
		/// <summary>
		/// 取得或設定影像的地理座標。
		/// </summary>
		public GeoCoordinate GeoCoordinate
		{
			get
			{
				return this.GetProperty<GeoCoordinate>("GeoCoordinate");
			}
			set
			{
				this.SetProperty("GeoCoordinate", value);
			}
		}
		#endregion
		#region GetAsReadOnly
		/// <summary>
		/// 取得唯讀的 GenericImageMetadata。 
		/// </summary>
		/// <returns>唯讀的 GenericImageMetadata。 </returns>
		public override IMetadata GetAsReadOnly()
		{
			if (this.IsReadOnly)
				return this;
			return new GenericImageMetadata(this, true);
		}
		#endregion
		#region ISO
		/// <summary>
		/// 取得或設定 ISO 值。
		/// </summary>
		public int? ISO
		{
			get
			{
				return this.GetProperty<int?>("ISO");
			}
			set
			{
				this.SetProperty("ISO", value);
			}
		}
		#endregion
		#region LensManufacturer
		/// <summary>
		/// 取得或設定鏡頭製造商。
		/// </summary>
		public string LensManufacturer
		{
			get
			{
				return this.GetProperty<string>("LensManufacturer");
			}
			set
			{
				this.SetProperty("LensManufacturer", value);
			}
		}
		#endregion
		#region LensModel
		/// <summary>
		/// 取得或設定鏡頭型號。
		/// </summary>
		public string LensModel
		{
			get
			{
				return this.GetProperty<string>("LensModel");
			}
			set
			{
				this.SetProperty("LensModel", value);
			}
		}
		#endregion
		#region Orientation
		/// <summary>
		/// 取得或設定影像方向。
		/// </summary>
		public ImageOrientation? Orientation
		{
			get
			{
				return this.GetProperty<ImageOrientation?>("Orientation");
			}
			set
			{
				this.SetProperty("Orientation", value);
			}
		}
		#endregion
		#region People
		/// <summary>
		/// 取得或設定影像中的人員資訊。
		/// </summary>
		public PersonRegion[] People
		{
			get
			{
				return this.GetProperty<PersonRegion[]>("People");
			}
			set
			{
				this.SetProperty("People", value);
			}
		}
		#endregion
		#region ShutterSpeed
		/// <summary>
		/// 取得或設定快門速度。
		/// </summary>
		public URational? ShutterSpeed
		{
			get
			{
				return this.GetProperty<URational?>("ShutterSpeed");
			}
			set
			{
				this.SetProperty("ShutterSpeed", value);
			}
		}
		#endregion
	}
}
